package com.example.demoapp.exception;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import com.example.demoapp.pojo.Result;
/**
 * 捕获全局错误的类
 */

@RestControllerAdvice
@Order(99)
public class GlobalExceptionHandler {
//    @ExceptionHandler(Exception.class)
//    public Result exceptionHandler(Exception e) {
//        e.printStackTrace();
//        return Result.fail();
//    }

    @ExceptionHandler(BusinessException.class)
    public Result exceptionHandler(BusinessException e) {
        return Result.fail(e.getCode(),e.getMessage());
    }
}



